exec sp_configure 'show advanced options',1  
reconfigure  
exec sp_configure 'Ad Hoc Distributed Queries',1  
reconfigure

DECLARE @tbName NVARCHAR(max)
DECLARE @sql NVARCHAR(MAX)
DECLARE csr_tabName CURSOR FOR 
	SELECT Name FROM SysObjects Where XType='U' ORDER BY Name
OPEN  csr_tabName
FETCH NEXT FROM csr_tabName INTO @tbName
WHILE(@@FETCH_STATUS=0)
BEGIN

	SET @sql='
					INSERT INTO '+@tbName+'
					SELECT  *  FROM OPENDATASOURCE(''SQLOLEDB'',''Data Source=192.0.0.248 ;User ID=sa;Password=sa*^68'' ).HNPrjSuperviseDB_ForTest.dbo.'+@tbName
	SET @sql='DELETE FROM '+@tbName 
	EXEC(@sql)
	FETCH NEXT FROM csr_tabName INTO @tbName

END
CLOSE csr_tabName
DEALLOCATE csr_tabName
  


  